//package com.example.project_springboot.filter;
//
//import com.alibaba.fastjson.JSONObject;
//import com.example.project_springboot.pojo.Result;
//import com.example.project_springboot.utils.JwtUtils;
//import org.springframework.context.annotation.Configuration;
//
//import javax.servlet.*;
//import javax.servlet.annotation.WebFilter;
//import javax.servlet.http.HttpServletRequest;
//import java.io.IOException;
//
////@WebFilter(urlPatterns = "/*")
//@Configuration
//public class ServerFilter implements Filter {
//    @Override
//    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//        HttpServletRequest hsr = (HttpServletRequest) servletRequest;
//        String uri = hsr.getRequestURI();
//        boolean b = uri.contains("/login");
//        if (!b){
//            String s = hsr.getHeader("token");
//            if (s != null){
//                JwtUtils.parseJWT(s);
//                filterChain.doFilter(servletRequest,servletResponse);
//            }else {
//                Result error = Result.error("错误");
//                String o = JSONObject.toJSONString(error);
//                servletResponse.setContentType("application/json");
//                servletResponse.getWriter().write(o);
//            }
//        }
//        filterChain.doFilter(servletRequest,servletResponse);
//    }
//}
